//
//  UpdateIssueJobViewController.m
//  PYWGetColor
//
//  Created by 杜文杰 on 2018/6/28.
//  Copyright © 2018年 dwj. All rights reserved.
//

#import "UpdateIssueJobViewController.h"
#import "IssueJobCollectionViewCell.h"
#import "MyUITextField.h"

@interface UpdateIssueJobViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UITextViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, strong) UIView *contentView;
@property (nonatomic, strong) NSMutableArray *dataArray;

@property (nonatomic, strong) UIImageView *loadImgView;// 上传的照片
@property (nonatomic, strong) MyUITextField *textField1;// 需求标题textField
@property (nonatomic, strong) UITextView *textView;// 需求说明
@property (nonatomic, strong) UITextField *gangweidwnField; // 岗位最低工资
@property (nonatomic, strong) UITextField *gangweiupField; // 岗位最高工资
@property (nonatomic, strong) UISwitch *swithButton;// 开关
@property (nonatomic, assign) BOOL isOnorOff;// 开关
@property (nonatomic, strong) NSString *serviceId;// 分类ID
@property (nonatomic, strong) NSMutableArray *imagesDataArray;
@end

@implementation UpdateIssueJobViewController
/**
 参数名    必选    类型    说明
 uid    是    int    uid
 token    是    string    密码
 jobid    否    string    服务技能id
 */
- (void)getDataInfomation {
    [[AFAppDotNetAPIClient sharedClient] POST:@"interface.php?m=jobdetail" parameters:@{@"uid":[UserModel sharedInstanced].userId,@"token":[UserModel sharedInstanced].token,@"jobid":self.dataDic[@"jobid"]} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"error_code"] isEqualToString:@"0"]) {
            NSDictionary *dic = responseObject[@"data"];
            self.textField1.text = dic[@"jobtitle"];
            self.textView.text = dic[@"jobdesc"];
            UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:dic[@"jobimg"]]]];
            if (image != nil && image != NULL) {
                [self.imagesDataArray addObject:image];
            }
            
            [self.loadImgView sd_setImageWithURL:[NSURL URLWithString:dic[@"jobimg"]]];
            self.gangweidwnField.text = dic[@"low"];
            self.gangweiupField.text  = dic[@"high"];
            if ([dic[@"can_bargin"] isEqualToString:@"1"]) {
                self.isOnorOff = YES;
                self.swithButton.on = YES;
            }else{
                self.isOnorOff = NO;
                self.swithButton.on = NO;
            }
            // 所有分类不选中状态 0
            for (int i = 0; i < self.dataArray.count; i++) {
                self.dataArray[i][@"value"] = @"0";
            }
            // 查到后台返回选中状态的 分类id对应数组第几个元素  根据i制成选中状态
            for (int i = 0; i < self.dataArray.count; i++) {
                NSDictionary *dictionary = self.dataArray[i];
                if ([dictionary[@"catid"] isEqualToString:dic[@"job_cat"]]) {
                    self.dataArray[i][@"value"] = @"1";
                }
            }
            [self.collectionView reloadData];
        }else{
            ShowMessage(@"操作失败");
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self showError:error];
    }];
}

- (void)saveJobToServer{
    [self showprogressHUD];
    NSString *biaotiStr = self.textField1.text; // 标题
    NSString *shuomingStr = self.textView.text; // 说明
    NSString *zdgz = self.gangweidwnField.text; // 岗位最低薪资
    NSString *zggz = self.gangweiupField.text;  // 岗位最高薪资
    if (biaotiStr.length <= 0 || biaotiStr == nil || biaotiStr == NULL) {
        ShowMessage(@"请输入标题");
    }
    if (shuomingStr.length <= 0 || shuomingStr == nil || shuomingStr == NULL) {
        ShowMessage(@"请输入需求说明");
    }
    NSString *onoffStr;
    if (self.isOnorOff) {// 开关状态
        NSLog(@"开");
        onoffStr = @"1";
    }else{
        NSLog(@"关");
        onoffStr = @"2";
    }
    if (self.serviceId.length <= 0 || self.serviceId == nil || self.serviceId == NULL) {
        for (NSDictionary *dic  in self.dataArray) {
            if ([dic[@"value"] isEqualToString:@"1"]) {
                self.serviceId = dic[@"catid"];
            }
        }
    }
    
    NSDictionary *parameter = @{@"user_id":[UserModel sharedInstanced].userId,@"token":[UserModel sharedInstanced].token,@"jobid":self.dataDic[@"jobid"],@"service":self.serviceId,@"title":biaotiStr,@"content":shuomingStr,@"high":zggz,@"low":zdgz,@"is":onoffStr};
    [[AFAppDotNetAPIClient sharedClient] POST:@"interface.php?m=savejob" parameters:parameter constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        if (self.imagesDataArray.count > 0) {
            for (UIImage *img in self.imagesDataArray) {
                NSData *data = UIImageJPEGRepresentation(img, .2);
                NSString *imgName = [NSString stringWithFormat:@"%ld.jpg",(unsigned long)[NSDate date].timeIntervalSince1970];
                [formData appendPartWithFileData:data name:@"image" fileName:imgName mimeType:@"image/jpeg"];
            }
        }else{
            NSData *data = UIImageJPEGRepresentation(self.loadImgView.image, .1);
            NSTimeInterval time = [[NSDate date] timeIntervalSince1970];
            [formData appendPartWithFileData:data name:@"image" fileName:[NSString stringWithFormat:@"%ld.jpg",(NSUInteger)time] mimeType:@"image/jpeg"];
        }
        
    } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"error_code"] isEqualToString:@"0"]) {
            [self.view makeToast:@"发布成功" duration:1 position:CSToastPositionCenter title:nil image:nil style:nil completion:^(BOOL didTap) {
                [self.navigationController popViewControllerAnimated:YES];
            }];
        }else{
        }
        
        [self hiddenProgressHUD];
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self hiddenProgressHUD];
    }];
    
}

// 获取岗位分类
- (void)getTypesList {
    [[AFAppDotNetAPIClient sharedClient] POST:@"interface.php?m=jobcatlist" parameters:@{@"uid":[UserModel sharedInstanced].userId,@"token":[UserModel sharedInstanced].token} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if ([responseObject[@"error_code"] isEqualToString:@"0"]) {
            NSMutableArray *mudataArray = @[].mutableCopy;
            NSMutableArray *array = responseObject[@"data"];
            for (int i = 0; i < array.count; i++) {
                NSMutableDictionary *muDictionary = @{@"title":@"汽车内饰",@"value":@"0",@"catid":@""}.mutableCopy;//按自己所需格式添加字典
                [mudataArray addObject:muDictionary];
            }
            for (int i = 0; i < mudataArray.count; i++) {
                NSString * stra = array[i][@"catname"];
                NSString *strb = array[i][@"catid"];
                mudataArray[i][@"title"] = stra;
                mudataArray[i][@"catid"] = strb;
            }
            self.dataArray = mudataArray; // 选择分类数据源
//            self.dataArray[0][@"value"] = @"1";
//            [self.collectionView reloadData];
            [self getDataInfomation];
        }else{
            ShowMessage(@"操作失败");
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        [self showError:error];
    }];
}
#pragma mark -- event
- (void)selectImgAction{
    NSLog(@"选择照片");
    [self selectPhotoAlbumWithSelectPhotoHandle:^(UIImage *image) {
        self.loadImgView.image = image;
        [self.imagesDataArray removeAllObjects];
//        [self.imagesDataArray addObject:image];
    }];
}
- (void)switchAction:(UISwitch *)sender{
    NSLog(@"开关%d",sender.on);
    self.isOnorOff = sender.on;
    if (self.isOnorOff) {// 开关状态
        NSLog(@"开");
    }else{
        NSLog(@"关");
    }
}
- (void)commitBtnAction{
    [self saveJobToServer];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if (@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
    self.navigationController.navigationBar.hidden = NO;
    self.navigationItem.title = @"发布岗位";
    [self.view addSubview:self.tableView];
    [self getTypesList];
}

#pragma mark -- init
- (UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaTopHeight - SafeAreaBottomHeight) style:UITableViewStylePlain];
        _tableView.backgroundColor = getColor(whiteColor);
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.tableHeaderView = self.headerView;
        _tableView.tableFooterView = self.footerView;
    }
    return _tableView;
}
- (UIView *)headerView{
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaTopHeight - SafeAreaBottomHeight)];
        _headerView.backgroundColor = getColor(whiteColor);
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20 / WIDTH_6S_SCALE, 12 / HEIGHT_6S_SCALE, 100, 18)];
        label.font = DEF_FontSize_16;
        label.textColor = getColor(blackColor);
        label.textAlignment = NSTextAlignmentLeft;
        label.text = @"选择分类";
        [_headerView addSubview:label];
        [_headerView addSubview:self.collectionView];
        [_headerView addSubview:self.contentView];
        __weak __typeof(self)weakSelf = self;
        [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakSelf.collectionView.mas_bottom);
            make.left.bottom.right.equalTo(_headerView);
        }];
    }
    return _headerView;
}

- (UIView *)footerView{
    if (!_footerView) {
        _footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.01)];
    }
    return _footerView;
}

- (UICollectionView *)collectionView{
    if (!_collectionView) {
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake((SCREEN_WIDTH - 40 / WIDTH_6S_SCALE - 30) / 4,30 / HEIGHT_6S_SCALE);
        flowLayout.minimumLineSpacing = 10;//横向距离
        flowLayout.minimumInteritemSpacing = 2;//竖向距离
        flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
        flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(20 / WIDTH_6S_SCALE, 40 / HEIGHT_6S_SCALE, SCREEN_WIDTH - 39 / WIDTH_6S_SCALE, 70 / HEIGHT_6S_SCALE) collectionViewLayout:flowLayout];
        _collectionView.backgroundColor = getColor(whiteColor);
        _collectionView.bounces = YES;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        _collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [_collectionView registerClass:[IssueJobCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([IssueJobCollectionViewCell class])];
    }
    return _collectionView;
}

- (UIView *)contentView{
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = [UIColor whiteColor];
        //线
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = getColor(dividerColor);
        //详细信息
        UILabel *label1 = [[UILabel alloc] init];
        label1.font = DEF_FontSize_16;
        label1.textAlignment = NSTextAlignmentLeft;
        label1.textColor = getColor(blackColor);
        label1.text = @"填写详细信息";
        //需求标题
        UILabel *label2 = [[UILabel alloc] init];
        label2.font = DEF_FontSize_14;
        label2.textAlignment = NSTextAlignmentLeft;
        label2.textColor = getColor(blackColor);
        label2.text = @"需求标题:";
        //需求标题textField
        MyUITextField *textField1 = [[MyUITextField alloc] init];
        textField1.font = DEF_FontSize_12;
        textField1.textAlignment = NSTextAlignmentLeft;
        textField1.textColor = getColor(blackColor);
        textField1.placeholder = @"请输入需求标题";
        textField1.layer.borderWidth = 1;
        textField1.layer.borderColor = getColor(textColor).CGColor;
        self.textField1 = textField1;
        //标题不为空
        UILabel *label3 = [[UILabel alloc] init];
        label3.font = DEF_FontSize_12;
        label3.textAlignment = NSTextAlignmentLeft;
        label3.textColor = getColor(textColor);
        label3.text = @"标题不能为空，最多可输入20个字符。";
        //需求说明
        UILabel *label4 = [[UILabel alloc] init];
        label4.font = DEF_FontSize_14;
        label4.textAlignment = NSTextAlignmentLeft;
        label4.textColor = getColor(blackColor);
        label4.text = @"需求说明:";
        //需求说明textView
        UITextView *textView = [[UITextView alloc] init];
        textView.font = DEF_FontSize_12;
        textView.textAlignment = NSTextAlignmentLeft;
        textView.textColor = getColor(textColor);
        textView.text = @"请输入需求说明";
        textView.layer.borderWidth = 1;
        textView.layer.borderColor = getColor(textColor).CGColor;
        textView.textContainerInset = UIEdgeInsetsMake(7, 6, 0, 6);
        textView.delegate = self;
        self.textView = textView;
        //上传照片
        UILabel *label5 = [[UILabel alloc] init];
        label5.font = DEF_FontSize_14;
        label5.textAlignment = NSTextAlignmentLeft;
        label5.textColor = getColor(blackColor);
        label5.text = @"上传照片:";
        //照片
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:@"btn_pic"];
        UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImgAction)];
        imageView.userInteractionEnabled = YES;
        [imageView addGestureRecognizer:gesture];
        self.loadImgView = imageView;
        
        //岗位薪资
        UILabel *label6 = [[UILabel alloc] init];
        label6.font = DEF_FontSize_14;
        label6.textAlignment = NSTextAlignmentLeft;
        label6.textColor = getColor(blackColor);
        label6.text = @"岗位薪资:";
        //textfile2
        UITextField *textField2 = [[UITextField alloc] init];
        textField2.font = DEF_FontSize_12;
        textField2.textAlignment = NSTextAlignmentCenter;
        textField2.textColor = getColor(blackColor);
        textField2.placeholder = @"最低薪资";
        //        textField2.text = @"2000";
        textField2.layer.borderWidth = 1;
        textField2.layer.borderColor = getColor(textColor).CGColor;
        self.gangweidwnField = textField2;
        //横线
        UIView *lineView2 = [[UIView alloc] init];
        lineView2.backgroundColor = getColor(blackColor);
        //textfile3
        UITextField *textField3 = [[UITextField alloc] init];
        textField3.font = DEF_FontSize_12;
        textField3.textAlignment = NSTextAlignmentCenter;
        textField3.textColor = getColor(blackColor);
        textField3.placeholder = @"最高薪资";
        //        textField3.text = @"4000";
        textField3.layer.borderWidth = 1;
        textField3.layer.borderColor = getColor(textColor).CGColor;
        self.gangweiupField = textField3;
        //是否可议价
        UILabel *label7 = [[UILabel alloc] init];
        label7.font = DEF_FontSize_14;
        label7.textAlignment = NSTextAlignmentLeft;
        label7.textColor = getColor(blackColor);
        label7.text = @"是否可议价:";
        //开关
        UISwitch *swithButton = [[UISwitch alloc] init];
        swithButton.onTintColor = getColor(@"3eceb2");
        swithButton.tintColor = [UIColor grayColor];
        swithButton.on = YES;
        [swithButton addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
        self.swithButton = swithButton;
        //提交岗位按钮
        UIButton *commitButton = [[UIButton alloc] init];
        commitButton.titleLabel.font = DEF_FontSize_16;
        commitButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        [commitButton setTitle:@"提交岗位" forState:UIControlStateNormal];
        [commitButton setTitleColor:getColor(whiteColor) forState:UIControlStateNormal];
        commitButton.backgroundColor = getColor(@"3eceb2");
        commitButton.layer.cornerRadius = 3;
        commitButton.layer.masksToBounds = YES;
        [commitButton addTarget:self action:@selector(commitBtnAction) forControlEvents:UIControlEventTouchUpInside];
        
        //添加控件
        [_contentView addSubview:lineView];
        [_contentView addSubview:label1];
        [_contentView addSubview:label2];
        [_contentView addSubview:textField1];
        [_contentView addSubview:label3];
        [_contentView addSubview:label4];
        [_contentView addSubview:textView];
        [_contentView addSubview:label5];
        [_contentView addSubview:imageView];
        [_contentView addSubview:label6];
        [_contentView addSubview:textField2];
        [_contentView addSubview:lineView2];
        [_contentView addSubview:textField3];
        [_contentView addSubview:label7];
        [_contentView addSubview:swithButton];
        [_contentView addSubview:commitButton];
        
        //约束
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_contentView).offset(12 / HEIGHT_6S_SCALE);
            make.left.equalTo(_contentView).offset(10 / WIDTH_6S_SCALE);
            make.right.equalTo(_contentView).offset(-10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(1);
        }];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView.mas_bottom).offset(8 / HEIGHT_6S_SCALE);
            make.left.equalTo(_contentView).offset(20 / WIDTH_6S_SCALE);
        }];
        [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(label1);
            make.top.equalTo(label1.mas_bottom).offset(14 / HEIGHT_6S_SCALE);
        }];
        [textField1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(label2);
            make.left.equalTo(label2.mas_right).offset(4 / WIDTH_6S_SCALE);
            make.width.mas_equalTo(230 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(30 / HEIGHT_6S_SCALE);
        }];
        [label3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(textField1);
            make.top.equalTo(textField1.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
        }];
        [label4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(label2);
            make.top.equalTo(label3.mas_bottom).offset(14 / HEIGHT_6S_SCALE);
        }];
        [textView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(label4);
            make.left.equalTo(label4.mas_right).offset(4 / WIDTH_6S_SCALE);
            make.right.equalTo(_contentView).offset(-20 / WIDTH_6S_SCALE);
            make.height.mas_offset(120 / HEIGHT_6S_SCALE);
        }];
        [label5 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(label2);
            make.top.equalTo(textView.mas_bottom).offset(14 / HEIGHT_6S_SCALE);
        }];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(textField1);
            make.top.equalTo(label5);
            make.width.height.mas_equalTo(40 / WIDTH_6S_SCALE);
        }];
        [textField2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(imageView);
            make.top.equalTo(imageView.mas_bottom).offset(14 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(60 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(textField1);
        }];
        [label6 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(label2);
            make.centerY.equalTo(textField2);
        }];
        [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(textField2.mas_right).offset(4 / WIDTH_6S_SCALE);
            make.centerY.equalTo(textField2);
            make.width.mas_equalTo(8 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(1);
        }];
        [textField3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lineView2.mas_right).offset(4 / WIDTH_6S_SCALE);
            make.centerY.equalTo(textField2);
            make.width.height.equalTo(textField2);
        }];
        [label7 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(textField3.mas_right).offset(10 / WIDTH_6S_SCALE);
            make.centerY.equalTo(textField3);
        }];
        [swithButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(label7.mas_right).offset(6 / WIDTH_6S_SCALE);
            make.centerY.equalTo(textField3);
        }];
        [commitButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(textField3.mas_bottom).offset(30 / HEIGHT_6S_SCALE);
            make.left.equalTo(_contentView).offset(10 / WIDTH_6S_SCALE);
            make.right.equalTo(_contentView).offset(-10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(50 / HEIGHT_6S_SCALE);
        }];
    }
    return _contentView;
}
#pragma mark -- UICollectionViewDelegate,UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    IssueJobCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([IssueJobCollectionViewCell class]) forIndexPath:indexPath];
    cell.model = self.dataArray[indexPath.row];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    for (int i = 0; i < self.dataArray.count; i++) {
        self.dataArray[i][@"value"] = @"0";
    }
    self.dataArray[indexPath.row][@"value"] = @"1";
    self.serviceId = self.dataArray[indexPath.row][@"catid"];
    [self.collectionView reloadData];
}

#pragma mark -- UITextViewDelegate
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
    if ([textView.text isEqualToString:@"请输入需求说明"]) {
        textView.text = @"";
        textView.textColor = getColor(blackColor);
    }
    return YES;
}
- (BOOL)textViewShouldEndEditing:(UITextView *)textView{
    if ([textView.text isEqualToString:@""]) {
        textView.text = @"请输入需求说明";
        textView.textColor = getColor(textColor);
    }
    return YES;
}

#pragma mark -- dataArray

- (NSMutableArray *)dataArray{
    if (!_dataArray) {
        //        _dataArray = @[@{@"title":@"汽车内饰",@"value":@"1"}.mutableCopy,
        //                       @{@"title":@"汽车外饰",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"维修保养",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"电子电器",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"清洁美容",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"改装配件",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"安全出行",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"其他",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"abc",@"value":@"0"}.mutableCopy,
        //                       @{@"title":@"ddd",@"value":@"0"}.mutableCopy
        //                       ].mutableCopy;
        _dataArray = @[].mutableCopy;
    }
    return _dataArray;
}
- (NSMutableArray *)imagesDataArray
{
    if (!_imagesDataArray) {
        _imagesDataArray = @[].mutableCopy;
    }
    return _imagesDataArray;
}
@end

